/*
 * Copyright (c) 2024 iSOFT INFRASTRUCTURE SOFTWARE CO., LTD.
 * easyAda is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */


#include <plat/config.h>
#include <tools/macros.h>
#include <core/addrspace.h>
#include <uapi/bootinfo.h>

extern unsigned long k_ro_start, k_ro_end;
extern unsigned long boot_end;
extern unsigned long k_text_start, k_text_end;
extern unsigned long k_data_start, k_data_end;
extern unsigned long rs_ro_start, rs_ro_end;
extern unsigned long k_rw_start, k_rw_end;
extern unsigned long k_stack_start, k_stack_end;
extern unsigned long bss_start, bss_end;
extern unsigned long k_rw_start;

void clean_bss(void)
{
    long *src = (long *)&bss_start;
    long *dst = (long *)&bss_end;
    while (src < dst) {
        *src++ = 0;
    }
}

void relocate_data(void)
{
    clean_bss();
    dprintf("clean_bss!\n");

    dprintf("k_ro_start:%x,k_ro_end;%x\n", &k_ro_start, &k_ro_end);
    dprintf("boot_end;:%x\n", &boot_end);
    dprintf("k_text_start:%x,k_text_end;%x!\n", &k_text_start, &k_text_end);
    dprintf("k_data_start:%x,k_data_end:%x\n", &k_data_start, &k_data_end);
    dprintf("k_rw_start:%x,k_rw_end;%x!\n", &k_rw_start, &k_rw_end);
    dprintf("k_stack_start:%x,k_stack_end:%x\n", &k_stack_start, &k_stack_end);
    dprintf("bss_start:%x,bss_end;%x!\n", &bss_start, &bss_end);

}
